package com.aconcagua.mvc.service.support {
  import com.aconcagua.mvc.service.ServiceInvoker;
  
  import mx.rpc.IResponder;
  import mx.rpc.events.ResultEvent;

  public class LocalServiceInvoker implements ServiceInvoker {
    private var _operation: Function;
    private var _parameters: Array;

    public function LocalServiceInvoker(operation: Function, parameters: Array) {
      _operation = operation;
      _parameters = parameters;
    }

    public function invoke(callbackResponder: IResponder, synchronic: Boolean = false):void {
      var data:Object = _operation.apply(null, _parameters);
      callbackResponder.result(ResultEvent.createEvent(data));
    }
  }
}